#include "XInput.h"

XInput &XInput::init(void)
{
  pinMode(_pin, _pressLevel ? INPUT : INPUT_PULLUP);
  return *this;
}

bool XInput::read(void)
{
  return digitalRead(_pin) == _pressLevel;
}

bool XInput::read(unsigned long filterTime)
{
  if(read())
  {
    delay(filterTime);
    return read();
  }
  return false;
}
